<template>
  <div>
    <p v-for="({ count, goodsName }, index) in goodsArr" :key="index">
      <input
        type="Number"
        :value="count"
        @change="butChange([index, $event.target.value, $event.target])"
      /><span>{{ goodsName }}</span
      ><span v-show="count === 0">卖光了！！！</span>
    </p>
  </div>
</template>

<script>
export default {
  // name: "",
  data() {
    return {};
  },
  props: {
    goodsArr: {
      type: Array,
      required: true,
    },
  },
  methods: {
    butChange(values) {
      if (values[1] >= 0) {
        this.$emit("butchange", values);
      } else {
        values[2].value = 0;
      }
    },
  },
};
</script>

<style scoped></style>
